<?php
class TestController extends Zend_Controller_Action
{	
	public function init()
	{
		set_time_limit(9999);
		ini_set('display_errors', 1);
		ini_set('memory_limit', '-1');
		$this->_country ='th';
		
		$this->_db		= new Common_Db('wms_'.$this->_country);
		$this->_dbbob		= new Common_Db('wms_'.$this->_country . '_bob');
	}
	
	public function indexAction()
	{
		$QOOSData = new QOOSData('th');
		$QOOSData->caculatorDateBetween();
		exit;
	}
	
	public function cancellationAction()
	{
		$strSku		= trim($this->_request->getParam('sku'));
		
		$strPath	= ROOT_SITE.'/data/_cancellation';
		$strPath	= $strPath.'/'.$strSku.'.data';
		
		$strContent	= @file_get_contents($strPath);
		$arrData	= $strContent ? json_decode($strContent, true) : null;
		
		$average_rate	= isset($arrData['average_rate']) ? $arrData['average_rate'] : null ;
		$total			= isset($arrData['total']) ? $arrData['total'] : null ;
		$cancel			= isset($arrData['cancel']) ? $arrData['cancel'] : null ;
		
		$arrResult		= array();
		if($total)
		{
			foreach($total as $date=>$value)
			{
				$arrResult[]	= array
				(
					'date'		=> $date,
					'total'		=> $value,
					'cancel'	=> isset($cancel[$date]) ? $cancel[$date] : null,
				);
			}
		}
		
		$this->view->arrResult		= $arrResult;
		$this->view->average_rate	= $average_rate;
	}
	
	public function testAction()
	{
		$obj	= new QSupplier('vi');
		$arr	= $obj->getWeekday();
		echo '<pre>';
		print_r($arr);
		echo '</pre>';
	}
}
?>
